class WallRenderer : public IBlockRenderer
{
public:
	ITexture *Texture;

	WallRenderer(ITexture *texture) :
		Texture(texture)
	{
	}

	int GetTypeData(const int &data) { return data; }
	
	void Render(Schematic *schematic, RendererBase *renderer, const Block &block, const Point3i &position)
	{
		Point2i texPos = (block.Data == 1) ? Point2i(4 * 16, 2 * 16) : Point2i(0, 1 * 16);

		auto &north = schematic->GetBlock(position.X, position.Y, position.Z + 1);
		auto &south = schematic->GetBlock(position.X, position.Y, position.Z - 1);
		auto &east = schematic->GetBlock(position.X + 1, position.Y, position.Z);
		auto &west = schematic->GetBlock(position.X - 1, position.Y, position.Z);
		auto &top = schematic->GetBlock(position.X, position.Y + 1, position.Z);
		auto &bottom = schematic->GetBlock(position.X, position.Y - 1, position.Z);

		if (north != Block::Empty && south != Block::Empty &&
			(east == Block::Empty && west == Block::Empty && top == Block::Empty))
			renderer->Draw(Box(Texture, Point3i(6, 13, 16), Point3i(5, 3, 0)).SetAll(texPos));
		else if (east != Block::Empty && west != Block::Empty &&
			(north == Block::Empty && south == Block::Empty && top == Block::Empty))
			renderer->Draw(Box(Texture, Point3i(16, 13, 6), Point3i(0, 3, 5)).SetAll(texPos));
		else
		{
			if (north != Block::Empty)
				renderer->Draw(Box(Texture, Point3i(6, 13, 4), Point3i(5, 3, 12)).SetAll(texPos));
			if (south != Block::Empty)
				renderer->Draw(Box(Texture, Point3i(6, 13, 4), Point3i(5, 3, 0)).SetAll(texPos));
			
			if (east != Block::Empty)
				renderer->Draw(Box(Texture, Point3i(4, 13, 6), Point3i(12, 3, 5)).SetAll(texPos));
			if (west != Block::Empty)
				renderer->Draw(Box(Texture, Point3i(4, 13, 6), Point3i(0, 3, 5)).SetAll(texPos));

			renderer->Draw(Box(Texture, Point3i(8, 16, 8), Point3i(4, 0, 4)).SetAll(texPos));
		}
	}
};